﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs" Inherits="WebApplication5.WebForm6" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        // JavaScript Document
        function validateForm() {
            //H&#7885; ph&#7843;i &#273;&#432;&#7907;c &#273;i&#7873;n
            var ho = document.forms["myForm"]["ho"].value;
            if (ho == "") {
                alert("H&#7885; không &#273;&#432;&#7907;c &#273;&#7875; tr&#7889;ng");
                return false;
            }
            //Tên ph&#7843;i &#273;&#432;&#7907;c &#273;i&#7873;n
            var ten = document.forms["myForm"]["ten"].value;
            if (ten == "") {
                alert("Tên không &#273;&#432;&#7907;c &#273;&#7875; tr&#7889;ng");
                return false;
            }
            //Email ph&#7843;i &#273;&#432;&#7907;c &#273;i&#7873;n chính xác
            var email = document.forms["myForm"]["email"].value;
            var aCong = email.indexOf("@");
            var dauCham = email.lastIndexOf(".");
            if (email == "") {
                alert("Email không &#273;&#432;&#7907;c &#273;&#7875; tr&#7889;ng");
                return false;
            }
            else if ((aCong < 1) || (dauCham < aCong + 2) || (dauCham + 2 > email.length)) {
                alert("Email b&#7841;n &#273;i&#7873;n không chính xác");
                return false;
            }
            //Nh&#7853;p s&#7889; &#273;i&#7879;n tho&#7841;i
            var dienThoai = document.forms["myForm"]["dienThoai"].value;
            var kiemTraDT = isNaN(dienThoai);
            if (dienThoai == "") {
                alert("&#272;i&#7879;n tho&#7841;i không &#273;&#432;&#7907;c &#273;&#7875; tr&#7889;ng");
                return false;
            }
            if (kiemTraDT == true) {
                alert("&#272;i&#7879;n tho&#7841;i ph&#7843;i &#273;&#7875; &#7903; &#273;&#7883;nh d&#7841;ng s&#7889;");
                return false;
            }
            //Nh&#7853;p s&#7889; l&#432;&#7907;ng mu&#7889;n mua
            var soLuong = document.forms["myForm"]["soLuong"].value;
            var kiemTraSL = isNaN(soLuong);
            if ((soLuong == "") || (soLuong <= 0)) {
                alert("S&#7889; l&#432;&#7907;ng không &#273;&#432;&#7907;c &#273;&#7875; tr&#7889;ng và ph&#7843;i l&#7899;n h&#417;n 0");
                return false;
            }
            if (soLuong > 100) {
                alert("S&#7889; l&#432;&#7907;ng mua không &#273;&#432;&#7907;c l&#7899;n h&#417;n 100");
                return false;
            }
            if (kiemTraSL == true) {
                alert("S&#7889; l&#432;&#7907;ng mua ph&#7843;i &#273;&#7875; &#7903; &#273;&#7883;nh d&#7841;ng s&#7889;");
                return false;
            }
            //Ch&#7885;n ngày nh&#7853;n hàng
            var nm = document.forms["myForm"]["ngaymua"].value;
            if (nm == "") {
                alert("Ngày không &#273;&#432;&#7907;c &#273;&#7875; tr&#7889;ng");
                return false;
            }
            //Ch&#7885;n ki&#7875;u thanh toán
            var ck = document.getElementById("ck");
            var tt = document.getElementById("tt");
            if ((ck.checked == false) && (tt.checked == false)) {
                alert("B&#7841;n ph&#7843;i ch&#7885;n m&#7897;t ki&#7875;u thanh toán");
                return false;
            }
        }
</script>

<br />
<form action="#" method="post" name="myForm" onsubmit="return validateForm()">
<table bgcolor="#DDDDDD" id="formdangky" style="width: 450px;">
<tbody>
<tr>
    <td class="tenhang" width="118">H&#7885;:</td>
    <td width="320"><input name="ho" type="text" runat="server" /></td>
  </tr>
<tr>
    <td class="tenhang">Tên:</td>
    <td><input name="ten" type="text" runat="server" /></td>
  </tr>
<tr>
    <td class="tenhang">Email:</td>
    <td><input name="email" type="text" /></td>
  </tr>
<tr>
    <td class="tenhang">S&#7889; &#272;i&#7879;n Tho&#7841;i:</td>
    <td><input maxlength="11/" name="dienThoai" type="text" /></td>
  </tr>
<tr>
    <td class="tenhang">S&#7889; L&#432;&#7907;ng Mua:</td>
    <td><input name="soLuong" type="text" /></td>
  </tr>
<tr>
    <td class="tenhang">Ngày Nh&#7853;n Hàng:</td>
    <td><input id="datepicker" name="ngaymua" type="text" /></td>
  </tr>
<tr>
    <td class="tenhang">Thanh Toán:</td>
    <td><input id="ck" name="thanhToan" type="radio" value="chuyenKhoan" /> Chuy&#7875;n Kho&#7843;n
        <input id="tt" name="thanhToan" type="radio" value="trucTiep" /> Tr&#7921;c Ti&#7871;p Khi Giao Hàng
    </td>
  </tr>
<tr>
    <td><input name="Submit" type="submit" value="&#272;&#259;ng Ký Mua" /></td>
    <td><input name="Reset" type="reset" value="Xóa" /></td>
  </tr>
</tbody></table>
</form>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>
